//
//  MSDetailVImgView.m
//  MSJD
//
//  Created by xiangbo on 2018/11/7.
//  Copyright © 2018 xiangbo. All rights reserved.
//

#import "MSVImgDetailView.h"

@implementation MSVImgDetailView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews{
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:14.f];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.text = @"这是标题";
    
    UIImage *whiteLoc =  [[UIImage imageNamed:@"Shape"] imageByTintColor:[UIColor whiteColor]];
    self.locImage = [[UIImageView alloc] initWithImage:whiteLoc];
    
    self.descLabel = [[UILabel alloc] init];
    self.descLabel.font = [UIFont systemFontOfSize:12];
    self.descLabel.textColor = [UIColor whiteColor];
    self.descLabel.text = @"这是位置";
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.locImage];
    [self addSubview:self.descLabel];
    
    [self.backImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    [self.locImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(12);
        make.bottom.equalTo(self.mas_bottom).offset(-12);
        make.width.mas_equalTo(self.locImage.width);
        make.height.mas_equalTo(self.locImage.height);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.locImage);
        make.right.equalTo(self).offset(-12);
        make.bottom.equalTo(self.locImage.mas_top).offset(-8);
    }];
    
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.locImage.mas_right).offset(4);
        make.centerY.equalTo(self.locImage);
        make.right.equalTo(self.titleLabel);
    }];
}

- (void)setDetailData:(id)detailData{
    [super setDetailData:detailData];
    if ([detailData isKindOfClass:[MSFoodContentModel class]]) {
        MSFoodContentModel *model = (MSFoodContentModel *)detailData;
        self.titleLabel.text = model.title;
        self.descLabel.text = model.subTitle;
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
